import Vue from 'vue'
import Router from 'vue-router'



Vue.use(Router)

import Layout from '../views/layout/Layout'

export const constantRoutes = [
    { path: '/login', component: () => import('@/views/login/index'), hidden: true },
    { path: '/404', component: () => import('@/views/404'), hidden: true },
    {
      path: '/',
      component: Layout,
      redirect: '/dashboard',
      name: 'Dashboard',
      children: [{
        path: 'dashboard',
        component: () => import('@/views/dashboard/index'),
        meta: { title: '首页', icon: 'dashboard' }
      }]
    }]

export const asyncRoutes = [
    {
        path: '/staff',
        component: Layout,
        redirect: '/staff/table',
        name: '职工管理',
        meta: { title: '职工管理', icon: 'example' },
        children: [{
                path: 'table',
                name: '职工列表',
                component: () =>
                    import ('@/views/manager/staff/list'),
                meta: { title: '职工列表', icon: 'table' }
            },
            {
                path: 'save',
                name: '添加职工',
                component: () =>
                    import ('@/views/manager/staff/save'),
                meta: { title: '添加职工', icon: 'tree' }
            },
            {
                path: 'edit/:id',name: 'managerStaffEdit',
                component: () =>
                    import ('@/views/manager/staff/save'),
                meta: { title: '编辑职工', noCache: true },
                hidden: true}
        ]
    },

    {
        path: '/section',
        component: Layout,
        redirect: '/section/table',
        name: '部门管理',
        meta: { title: '部门管理', icon: 'example' },
        children: [{
                path: 'table',
                name: '部门列表',
                component: () =>
                    import ('@/views/manager/section/list'),
                meta: { title: '部门列表', icon: 'table' }
            },
            {
                path: 'save',
                name: '添加部门',
                component: () =>
                    import ('@/views/manager/section/save'),
                meta: { title: '添加部门', icon: 'tree' }
            },
            {
                path: 'edit/:id',name: 'managerSectionEdit',
                component: () =>
                    import ('@/views/manager/section/save'),
                meta: { title: '编辑部门', noCache: true },
                hidden: true}
        ]
    },

    {
        path: '/banner',
        component: Layout,
        redirect: '/banner/table',
        name: '公告管理',
        meta: { title: '公告管理', icon: 'example' },
        children: [{
                path: 'table',
                name: '公告列表',
                component: () =>
                    import ('@/views/manager/banner/list'),
                meta: { title: '公告列表', icon: 'table' }
            },
            {
                path: 'save',
                name: '添加公告',
                component: () =>
                    import ('@/views/manager/banner/save'),
                meta: { title: '添加公告', icon: 'tree' }
            }
        ]
    },

    {
        path: '/category',
        component: Layout,
        redirect: '/category/list',
        name: '资产分类管理',
        meta: { title: '资产分类管理', icon: 'example' },
        children: [{
                path: 'list',
                name: '资产分类列表',
                component: () =>
                    import ('@/views/manager/category/list'),
                meta: { title: '资产分类列表', icon: 'table' }
            },
            {
                path: 'save',
                name: '添加资产分类',
                component: () =>
                    import ('@/views/manager/category/save'),
                meta: { title: '添加资产分类', icon: 'tree' }
            }

        ]
    },
    {
        path: '/asset',
        component: Layout,
        redirect: '/asset/list',
        name: '资产管理',
        meta: { title: '资产管理', icon: 'example' },
        children: [{
                path: 'list',
                name: '资产列表',
                component: () =>
                    import ('@/views/manager/asset/list'),
                meta: { title: '资产列表', icon: 'table' }
            },
            {
                path: 'depreciationList',
                name: '折旧统计',
                component: () =>
                    import ('@/views/manager/asset/depreciationList'),
                meta: { title: '折旧统计', icon: 'table' }
            },
            {
                path: 'outList',
                name: '资产借出与回收',
                component: () =>
                    import ('@/views/manager/asset/out'),
                meta: { title: '资产借出与回收', icon: 'table' }
            },
            {
                path: 'info',
                name: '添加资产',
                component: () =>
                    import ('@/views/manager/asset/info'),
                meta: { title: '添加资产', icon: 'tree' }
            },
            {
                path: 'info/:id',
                name: 'managerassetInfoEdit',
                component: () =>
                    import ('@/views/manager/asset/info'),
                meta: { title: '编辑资产基本信息', noCache: true },
                hidden: true
            },
            {
                path: 'publish/:id',
                name: 'managerassetPublishEdit',
                component: () =>
                    import ('@/views/manager/asset/publish'),
                meta: { title: '发布资产', noCache: true },
                hidden: true
            },
            {
                path: 'show',
                name: 'showPriceList',
                component: () =>
                    import ('@/views/manager/asset/show'),
                meta: { title: '发布资产', noCache: true },
                hidden: true
            }
        ]
    },
    {
        path: '/assetUpdate',
        component: Layout,
        redirect: '/assetUpdate/list',
        name: '资产处理',
        meta: { title: '资产处理', icon: 'example' },
        children: [{
                path: 'list',
                name: '资产维修',
                component: () =>
                    import ('@/views/manager/assetUpdate/repair'),
                meta: { title: '资产维修', icon: 'table' }
            },
            {
                path: 'applyList',
                name: '资产申请',
                component: () =>
                    import ('@/views/manager/assetUpdate/apply'),
                meta: { title: '资产申请', icon: 'table' }
            }
        ]
    }
]


const createRouter = () => new Router({
    mode: 'history',
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
  })

const router = createRouter()

export default router
